INITSEG     equ 0x9000
SYSSEG      equ 0x1000
SETUPSEG    equ 0x9020

start:
    cli                 ; 保护模式下中断机制尚未建立，应禁止中断
    mov ax, 0x00
    cld
do_move:                ; 将内核从0x10000移动到0x00
    mov es, ax
    add ax, 0x1000
    cmp ax, 0x9000
    jz  end_move
    mov ds, ax
    sub di, di
    sub si, si
    mov cx, 0x8000
    rep
    movsw               ; 每次移动64KB内容
    jmp do_move

end_move:
    mov ax, SETUPSEG
    mov ds, ax
    lgdt    [gdt_48]    ; 加载gdtr

    mov al, 2
    out 0x92, al        ; 开A20

    mov ax, 0x0001
    lmsw    ax          ; 设置CR0的PE位
    jmp 8:0

gdt:
    dw  0, 0, 0, 0
    dw  0x07ff, 0x0000, 0x9a00, 0x00c0
    dw  0x07ff, 0x0000, 0x9200, 0x00c0

gdt_48:
    dw  0x800
    dw  512 + gdt, 0x9  ; 0x90200+gdt